--[[
File: WoWProMainFrame.lua
Author: Jahwo
Last Change: xx.xx.xxxx xx:xx

Summary: Creates and handles the MainFrame
--]]



--[[		MainFrame OnLoad		]]--
function WoWPro:MainFrame_OnLoad()
	
	WoWPro_MainFrame:SetBackdropColor(0.3, 0.3, 0.3, 0.6)
	WoWPro_MainFrame:SetBackdropBorderColor(0.7, 0.7, 0.7, 0.5)
	
end



--[[--------------------------------------------------]]--
--[[					BUTTONS						  ]]--
--[[--------------------------------------------------]]--

--[[		ToggleClosed OnClick		]]--
function WoWPro:MainFrame_ToggleClosed_OnClick()
	this:Hide()
	WoWPro_MainFrame_ToggleOpen:Show()
end


--[[		ToggleOpen OnClick		]]--
function WoWPro:ToggleOpen_OnClick()
	this:Hide()
	WoWPro_MainFrame_ToggleClosed:Show() 
	
	--if WoWPro_TextFrame_ScrollFrame:GetVerticalScrollRange() > WoWPro_TextFrame_ScrollFrame:GetVerticalScroll() then
	--WoWPro_TextFrame_ScrollFrame:SetVerticalScroll(WoWPro_TextFrame_ScrollFrame:GetVerticalScroll() + 1)
	--end
end 

--[[		Options OnClick		]]--
function WoWPro:Options_OnClick()
	-- TESTING PURPOSES
	DEFAULT_CHAT_FRAME:AddMessage(GetTime())
	for i = 0,5, 1 do
		WoWPro:CreateStepFrame()
	end
	DEFAULT_CHAT_FRAME:AddMessage(GetTime())
end


--[[		Close OnClick		]]--
function WoWPro:Close_OnClick()

end 



--[[--------------------------------------------------]]--
--[[					SCROLLFRAME					  ]]--
--[[--------------------------------------------------]]--

--[[		ScrollFrame OnMouseDown		]]--
function WoWPro:ScrollFrame_OnMouseDown()
	WoWPro.StepsDragging = true
	_,WoWPro.lastYPos = GetCursorPosition()
end



--[[		ScrollFrame OnMouseUp		]]--
function WoWPro:ScrollFrame_OnMouseUp()
	WoWPro.StepsDragging = false
end



--[[		ScrollFrame OnMouseWheel		]]--
function WoWPro:ScrollFrame_OnMouseWheel()
	WoWPro:ScrollFrame_Scroll(20*arg1)			--arg1 is -1 or 1 depending on scrolling direction
end



--[[		ScrollFrame Scroll		]]--
function WoWPro:ScrollFrame_Scroll(offset)
	local ScrollFrame = WoWPro_MainFrame_ScrollFrame
	local currentPos = ScrollFrame:GetVerticalScroll()
	ScrollFrame:SetVerticalScroll(currentPos + offset)
end
	
	

--[[		ScrollChild OnUpdate (Dragging)		]]--
function WoWPro:ScrollChild_OnUpdate()
	if WoWPro.StepsDragging then
		local _,currentYPos = GetCursorPosition()
		local diff = currentYPos - WoWPro.lastYPos
		WoWPro:ScrollFrame_Scroll(diff)
		WoWPro.lastYPos = currentYPos
	end
end
